package com.hp.jdoss;

import com.hp.jdoss.config.JdossTemplate;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 *
 * @author dongxing
 */
@Slf4j
@RestController
@AllArgsConstructor(onConstructor_={@Autowired} )
@RequestMapping("/app/v1/files")
public class FileController {

   private final JdossTemplate jdossTemplate;

   /**
    * 上传文件
    *
    * @param file 资源
    * @return R(bucketName, filename)
    */
   @PostMapping
   public Map<String, String> uploadJd(@RequestParam("file") MultipartFile file) {
      Map<String, String> stringStringMap = jdossTemplate.putFile(file);
      return stringStringMap;
   }
}